package day5;

import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    // 什么类型的数组，就存什么类型的数据
    Visitor[] visitors = new Visitor[5];
    int index = 0; // 数组的索引
    while (true) {
        Visitor visitor = new Visitor();
        if (index == 5) break;
        System.out.print("请输入姓名(n退出)：");
        String name = input.next();
        if ("n".equals(name)) break;
        visitor.name = name;
        System.out.print("请输入年龄：");
        visitor.age = input.nextInt();
        visitor.buyTicket();
        visitors[index++] = visitor;
    }
    System.out.println("退出程序");
    // 统计下今天旅游的游客有哪些
    System.out.println("今日的游客总数为:" + index);
    for (int i = 0; i < index; i++) {
        System.out.println("第" + (i + 1) + "个游客为：" +
                visitors[i].name);
    }

}
}
